package manager.server.factory{
	import flash.utils.ByteArray;

	public class LoginCommand extends SocketCommandBase implements ISocketCommand {
		private var _userName:String;   //用户的名字
		private var _userID:String;     //用于标识当前用户的头像Id信息

		public function LoginCommand(type:int = 0, name:String = '', id:String = ''){
			super.type = type;
			_userName  = name;
			_userID    = id;
			write();
		}

		/**实现数据写入**/
		override public function write():void {
			super.write();
			byteArray.writeUTF(_userName);
			byteArray.writeUTF(_userID);
		}

		/**按类型接收到数据并进行解码操作**/
		override public function decodeSocketData(byteArray:ByteArray):ISocketCommand {
			super.decodeSocketData(byteArray);
			_userName = byteArray.readUTF();
			_userID   = byteArray.readUTF();
			
			return this;
		}
		
		/**登录名*/
		public function get userName():String {
			return _userName;
		}
		
		public function set userName(value:String):void {
			_userName = value;
		}
		
		/**登录ID*/
		public function get userID():String {
			return _userID;
		}
		
		public function set userID(value:String):void {
			_userID = value;
		}
	}
}